package base.template;

import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Random;

class Customer{
	private static long count=0;
	private final long id=count++;
	private Customer(){}
	public String toString() {
		return "customer "+id;
	}
	public static Generator<Customer> generator(){
		return new Generator<Customer>() {
			public Customer next() {
				return new Customer();
			}
		};
	}
}
class Teller{
	private static long count=0;
	private final long id=count++;
	private Teller(){}
	public String toString() {
		return "Teller "+id;
	}
	public static Generator<Teller> generator(){
		return new Generator<Teller>() {
			public Teller next() {
				return new Teller();
			}
		};
	}
}
public class BankTeller {
	public static void serve(Teller t,Customer c){
		System.out.println(t+" serves "+c);
	}
	public static void main(String[] args) {
		Random rand=new Random();
		Queue<Customer> line = new LinkedList<Customer>();
		Generators.fill(line, Customer.generator(), 15);
		
		List<Teller> tellers = new LinkedList<Teller>();
		Generators.fill(tellers, Teller.generator(), 5);
		
		for(Customer c:line){
			serve(tellers.get(rand.nextInt(tellers.size())), c);
		}
		
	}
}
